export const formItems = [];
export function linkTypeChange(val, formItems) {
  console.log(val, formItems);
  formItems.forEach((item) => {
    if (item.prop == "link") {
      if (val == 1) {
        item.isHide = true;
      }
      if (val == 2) {
        item.isHide = false;
      }
    }
    if (item.prop == "path") {
      if (val == 1) {
        item.isHide = false;
      }
      if (val == 2) {
        item.isHide = true;
      }
    }
  });
}
export const propList = [
  {
    label: "名称",
    prop: "name",
  },
  {
    label: "路径",
    slotName: "path",
  },
  {
    label: "类型",
    slotName: "type",
  },
  {
    label: "图标",
    slotName: "icon",
  },
  {
    label: "排序",
    prop: "sort",
  },
  {
    label: "是否启用",
    slotName: "status_text",
  },
  {
    label: "创建时间",
    prop: "created_at",
  },
  {
    label: "操作",
    slotName: "op",
    showOverflowTooltip: false,
    fixed: "right",
  },
];
export const dialogConfig = {
  title: "页面配置",
  formConfig: {
    labelWidth: "150px",
    colLayout: { span: 24 },
    formData: {},
    formItems: [
      {
        label: "名称",
        prop: "name",
        type: "input",
        placeholder: "请输入名称，显示在公众号我的页面中",
      },
      {
        label: "排序(越小越靠前)",
        prop: "sort",
        type: "input",
        placeholder: "请输入",
      },
      {
        label: "是否启用",
        prop: "status",
        type: "radio",
        radioList: [
          {
            label: "启用",
            value: 1,
          },
          {
            label: "禁用",
            value: 2,
          },
        ],
      },
      {
        label: "图标",
        prop: "icon",
        type: "custom",
      },
      {
        label: "图标颜色",
        prop: "icon_color",
        type: "custom",
      },
      {
        label: "跳转类型",
        prop: "type",
        type: "radio",
        change: linkTypeChange,
        radioList: [
          {
            label: "充值内部页面",
            value: 1,
          },
          {
            label: "外链",
            value: 2,
          },
        ],
      },
      {
        label: "跳转链接",
        prop: "link",
        type: "input",
        isHide: true,

        placeholder: "请输入跳转链接",
      },
      {
        prop: "path",
        label: "页面",
        type: "select",
        isHide: true,
        options: [],
        key: "path",
        change(e, formItems) {
          console.log(e, formItems);
        },
        value: "name",
        placeholder: "请选择",
        // lg: 6,
        otherOptions: {
          // style: "width:200px",
        },
      },
    ],
    formDataRules: {
      name: [{ required: true, message: "请输入", trigger: "blur" }],
      sort: [{ required: true, message: "请输入", trigger: "blur" }],
      // icon: [{ required: true, message: "请输入", trigger: "blur" }],
      status: [{ required: true, message: "请选择状态", trigger: "change" }],
      // icon_color: [
      //   { required: true, message: "请选择颜色", trigger: "change" },
      // ],
      type: [{ required: true, message: "请选择", trigger: "change" }],
      path: [{ required: true, message: "请选择", trigger: "blur" }],
      link: [{ required: true, message: "请输入", trigger: "blur" }],
    },
  },
};
